<template>
  <div class="news-list">
    <van-card
      v-for="item in newsList"
      :key="item.id"
      :title="item.title"
      :thumb="item.img_url"
      @click="goDetail('/home/newsinfo/',item.id)"
    >
      <!-- 新版插槽 -->
      <template #price>
        {{item.add_time}}
      </template>
      <!-- 旧版插槽 -->
      <template slot="num">
        点击 {{item.click}} 次
      </template>
    </van-card>
  </div>
</template>
<script>
// import mixins from '@/mixins'
export default {
  name: 'NewsList',
  data: () => ({
    newsList: []
  }),
  // mixins: [mixins],
  created() {
    this.getNewsList()
  },
  methods: {
    async getNewsList() {
      const res = await this.$http.getNewsList()
      this.newsList = res.message
    }
    // goDetail(id) {
    //   this.$router.push('/home/newsinfo/' + id)
    // }
  }
}
</script>
<style lang="less" scoped>
.news-list {
  .van-card__thumb {
    height: 53px;
  }
  .van-card__content {
    min-height: 53px;
  }
  .van-card__price {
    font-size: 12px;
    color: red;
  }
  .van-card__title {
    width: 230px;
    // overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
}
</style>